#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>

using namespace std; 

#define MAX_N	1000
#define MAX_M	10001

struct pn_s {
	int	price;
	int num; 
}; 

int exp_price, above_rate; 
struct pn_s pn[MAX_N]; 
int n; 

int price_lo, price_hi; 

int p2num[MAX_M]; 


/*
#define _pl2()  printf("get_raw_num: li=%d, price=%d, i=%d, r=%d, p=(%d, %d), n=(%d, %d)\n", \
		__LINE__, p, i, r, pn[i].price, pn[i+1].price, pn[i].num, pn[i+1].num)
*/
#define _pl2()

int get_raw_num(int p)
{
	int i, r=-1; 
	if (p>pn[n-1].price) {
		r = pn[n-1].num - (p-pn[n-1].price)*above_rate; 
		_pl2(); 
		return r; 
	}
	for (i=0; i<n-1; i++) {
		if (p==pn[i].price) {
			r = pn[i].num; 
			_pl2(); 
			return r; 
		} else if (p==pn[i+1].price) {
			r = pn[i+1].num; 
			_pl2(); 
			return r; 
		} else if (pn[i].price<p && p<pn[i+1].price) {
			r = (int)(pn[i].num + 1.0*(pn[i+1].num-pn[i].num)*(p-pn[i].price)/(pn[i+1].price-pn[i].price));
			_pl2(); 
			return r; 
		}
	}
	//printf("error, p=%d\n", p); 
	_pl2(); 
	return r; 
}

void convert(void)
{
	int i; 
	for (i=price_lo; i<=price_hi; i++) {
		p2num[i] = get_raw_num(i); 
		//printf("convert: price=%d, num=%d\n", i, p2num[i]); 
	}
}

int get_num(int p)
{
	if (p<price_lo || p>price_hi)
		return -1; 
	return p2num[p]; 
}

/*
#define _pl1()  printf("li=%d, num=%d, price=%d, cost=%d, subsidy=%d, profit=%d\n", \
		__LINE__, num, real_price, pn[0].price, subsidy, profit); 
*/

#define _pl1()

int get_profit(int real_price, int subsidy)
{
	int num, profit; 

	num = get_num(real_price); 
	profit = (real_price-pn[0].price+subsidy)*num; 
	_pl1(); 
	return profit; 
}

double f_rand(void)
{
	return 1.0*rand()/RAND_MAX; 
}

#if 0
#define _pl()  printf("li=%d, i=%d, price_limit=[%d, %d], exp_price=%d, exp_profit=%d, subsidy=%d, price=%d, profit=%d\n", \
					__LINE__, i, price_lo, price_hi, exp_price, exp_profit, subsidy, price, profit)
#else
#define _pl()
#endif

int is_best(int subsidy)
{
	int price, profit, exp_profit; 
	int i; 

	exp_profit = get_profit(exp_price, subsidy); 
	for (i=0; i<100; i++) {
		//_pl(); 
		price = price_lo + (int)(f_rand()*(price_hi-price_lo)); 
		profit = get_profit(price, subsidy); 
		if (profit>exp_profit) {
			return 0; 
		}
	}

	_pl(); 
	for (price=price_lo; price<=price_hi; price++) {
		profit = get_profit(price, subsidy); 
		_pl(); 
		if (profit>exp_profit) {
			return 0; 
		}
	}

	printf("%d\n", subsidy); 
	return 1; 
}

void solve(void)
{
	int price, subsidy, profit, exp_profit; 
	int fail, i, j; 
	
	srand(time(NULL)); 
	//is_best(-32); 
#if 1	
	for (subsidy=0; subsidy<=10000; subsidy++) {
		if (is_best(subsidy))
			return; 
	}
	for (subsidy=-1; subsidy>=-10000; subsidy--) {
		if (is_best(subsidy))
			return; 
	}
	printf("NO SOLUTION\n"); 
#endif
}

bool cmp(struct pn_s &a, struct pn_s &b)
{
	return a.price < b.price; 
}

int main()
{
	struct pn_s *p; 
	
//	freopen("p1023_03.in", "r", stdin); 
	scanf("%d", &exp_price); 
	while (1) {
		p = &pn[n]; 
		scanf("%d %d", &p->price, &p->num); 
		if (p->price<0)
			break; 
		n++; 
	}
	scanf("%d", &above_rate); 
	sort(pn, &pn[n], cmp); 
	/*
	for (int i=0; i<n; i++) { 
		printf("%d %d\n", pn[i].price, pn[i].num); 
	}*/
	
	price_lo = pn[0].price; 							
	price_hi = pn[n-1].price + pn[n-1].num/above_rate; 	

	get_raw_num(281); 
	convert(); 
	
	/*
	for (int i=price_lo; i<=price_hi; i++) { 
		printf("price=%d num=%d\n", i, p2num[i]); 
	} */

	solve(); 
	return 0; 
}


